/*
 *  Chromosome.h
 *  Genetski
 *
 *  Created by Srđan Rašić on 11/19/11.
 *
 */

#pragma once
#include <string>
#include <vector>

/**
 * Chromosome is an array of zeroes and ones (bits) that represents
 * possible solution of a problem (eq. minimum of function).
 * Class extends functionality of std::string for it's needs.
 */
class Chromosome : public std::string {
private:
	int _parts;
	int _partSize;
	
public:
	/**
	 * Initializes chromosome with random bits.
	 * @param parts Number of variables (dimensions)
	 * @param partSize Size of each part
	 */
	Chromosome(int parts, int partSize);
	
	/**
	 * Returns length of parts.
	 */
	int PartLength() const;
	
	/**
	 * Returns decimal representation of binary number.
	 * @param part Index of chromosome part that represents number
	 */
	double Value(int part);
	
	/**
	 * Returns decimal representation of all parts.
	 */
	std::vector<double> Values();
};